// BrowserRouter as Router  将BrowserRouter命名为Router
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import Home from '../views/Home'
import Music from '../views/Music'
import Detail from '../views/Detail'

const routes = [
    {
        path: "/",
        element: <Home />
    },
    {
        path: "/music",
        element: <Music />
    },
    {
        path: "/detail",
        element: <Detail />
    }
]

function RouterView() {
    return (
        <Router>
            <Routes>
                {/* <Route path="/" element={<Home />}></Route>
                <Route path="/music" element={<Music />}></Route> */}
                {routes.map(item => {
                    return (
                        <Route key={item.path} path={item.path} element={item.element}></Route>
                    )
                })}
            </Routes>
        </Router>
    )
}

export default RouterView